package lanqiao;
/**
 * @Project : AlgorithmLearning
 * @Package : LanQiao.PrepareForCompetition
 * @File : Q2377.java
 * @Author : WangRuoyu
 * @Date : 2023/3/30 11:29
 */

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Q2377 {

    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int res = 0;
        for (int i = 0; i < 5; ++i) {
            String year = br.readLine().split(" ")[0];
            if ((year.charAt(0) == year.charAt(2)) && (year.charAt(3) == year.charAt(1) + 1)) {
                res++;
            }
        }
        System.out.println(res);
    }
}
